
import {ReqGetUserInfo,ReqPassportLogout} from "@/api"
import {deleteToken} from "@/utils/auth"
import { Message } from "element-ui"
export default {
    namespaced:true,
    state:{
        userInfo:{}
    },
    mutations:{
        SAVE_USER_LIST(state,value){
            state.userInfo = value
        },
        DELE_USER_LIST(state){
            state.userInfo = {}
        }
    },
    actions:{
        async getUserInfo({commit}){
            let result = await ReqGetUserInfo()
            // console.log(result);
            if(result.code){
                return Promise.reject()
            }else{
                commit("SAVE_USER_LIST",result)
            }
        },
        async DeleteUserInfo({commit}){
            await ReqPassportLogout()
            deleteToken()
            commit("DELE_USER_LIST")
            Message.success("退出成功")
        },

    }
}